package com.im.partchat.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.im.partchat.R;
import com.im.partchat.bean.main.MainGirdBean;
import com.im.partchat.utils.Navigation;
import com.im.partchat.utils.ToastUtils;

import java.util.List;

/**
 * Created by fzl on 2017/4/14.
 * VersionCode: 1
 * Desc:
 */

public class MineGirdAdapter extends BaseAdapter {
    private Context mContext;
    private List<MainGirdBean> mainTypeBeanList;



    public MineGirdAdapter(Context context, List<MainGirdBean>beanList) {
        this.mContext = context;
        this.mainTypeBeanList = beanList;


    }

    @Override
    public int getCount() {
        return mainTypeBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return mainTypeBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (null == convertView) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.view_mine_gird_item, null);

            holder.imageView = (ImageView) convertView.findViewById(R.id.all_type_image);
            holder.textView = (TextView) convertView.findViewById(R.id.all_type_text);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                switch (position){
                    case 0:
                        ToastUtils.showShort("正在建设中……");
                        break;
                    case 1:
                        Navigation.navigateMyNote();
                        break;
                    case 2:
                        ToastUtils.showShort("正在建设中……");
                        break;
                    case 3:
                        break;
                    case 4:
                        Navigation.navigateMyPart();
                        break;
                    case 5:
                        ToastUtils.showShort("正在建设中……");
                        break;
                    case 6:
                        Navigation.navigatePayDues();

                        break;
                    case 7:
                        Navigation.navigateDocDownLoad();
                        break;

                }
            }
        });
        holder.imageView.setImageResource(mainTypeBeanList.get(position).getResId());
//        Glide.with(mContext).load(mainTypeBeanList.get(position).getResId())
//                .centerCrop()
//                .into(holder.imageView);
        holder.textView.setText(mainTypeBeanList.get(position).getTitle());
        return convertView;
    }

    public class ViewHolder {
        private ImageView imageView;
        private TextView textView;

    }
}
